import {getGoods,getGoodsList} from '@/api'

const state = {
    goodsInfo:{},
    goodsList:[]
}
const actions = {
    async getGoods({commit},id){
     let requls = await getGoods(id);
        console.log(requls);
        commit("GETGOODS",requls)
    },
    async getGoodsList({commit},id){
        let requls = await getGoodsList(id);
           console.log(requls);
           commit("GETGOODSLIST",requls)
       }
}
const mutations = {
    GETGOODS(state,goods){
        state.goodsInfo = goods
        console.log('goods========================',state.goods);
    },
    GETGOODSLIST(state,goodsListDB){
        state.goodsList = goodsListDB
        console.log('goodsList========================',state.goodsListDB);
    }
}
const getters = {
    goodsInfo(state){
        return state.goodsInfo
    },
    goodsList(state){
        return state.goodsList
    },
}


export default {
    state,
    actions,
    mutations,
    getters,
}